package com.eatme.web.security.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.security.core.GrantedAuthority;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;
@Entity
@Table(name="sys_resource")
public class Permission implements GrantedAuthority, Serializable {


    @Id
    @Column(name = "id",nullable = false)
    private String id;

    /**
     * permission_name
     */
    @Column(name = "name",nullable = false)
    private String authority;

    @Transient
    private String displayName;

    // @Transient
    @ManyToMany(mappedBy = "permissions")
    @JsonIgnore
    private Set<Role> roles;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public Set<Role> getRoles() {
        return roles;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }





}
